﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteLED.Master" AutoEventWireup="true" CodeBehind="ListArrival.aspx.cs" Inherits="lcs.Web.LED.ListArrival" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
   <script src="../Scripts/datetime.js"></script> 
    <script type="text/javascript"> 
        var mp3 = "/images/ding.wav";
        var toptime = "";
        var issopt = "";
        var timeid="";
        function playSound() {
            var borswer = window.navigator.userAgent.toLowerCase();
            if (borswer.indexOf("ie") >= 0) {
                //IE内核浏览器
                var strEmbed = '<embed name="embedPlay" src="'+mp3+'" autostart="true" hidden="true" loop="false"></embed>';
                if ($("body").find("embed").length <= 0)
                    $("body").append(strEmbed);
                var embed = document.embedPlay;

                //浏览器不支持 audion，则使用 embed 播放
                embed.volume = 100;
                //embed.play();这个不需要
            } else {
                //非IE内核浏览器
                var strAudio = "<audio id='audioPlay' src='"+mp3+"' hidden='true'>";
                if ($("body").find("audio").length <= 0)
                    $("body").append(strAudio);
                var audio = document.getElementById("audioPlay");

                //浏览器支持 audion
                audio.play();
            }
        }
     $(function () {           
            var h = $("#mycenter").height();
            $("#container").height(h-50);            
            InitGird();
            changeset();
            $("#myinterval").change(function () {
                changeset();
            });
     });
     function changeset() {
         var val = $("#myinterval").val();
         if (val != "-1") {
             issopt = "0";
             if (timeid != "")
                 clearInterval(timeid);
             timeid = setInterval(reloadgrid, val);
         }
         else {
             issopt = "1";
             clearInterval(timeid);
         }
     }
     function reloadgrid() {
         var queryParams = $('#tt').datagrid('options').queryParams;
         //getQueryParams(queryParams);
         $('#tt').datagrid('options').queryParams = queryParams;
         $("#tt").datagrid('reload');
     }
     
     //初始化表格
     function InitGird() {         
         $('#tt').datagrid({
             title: '最新到货物料', //表格标题
             url: 'GetLED.ashx?action=arrival', //请求数据的页面
             sortName: 'lastArrivalDate', //排序字段
             idField: 'did', //标识字段,主键
             iconCls: '', //标题左边的图标
             width: '100%', //宽度
             height: '100%', //宽度
             nowrap: false, //是否换行，True 就会把数据显示在一行里
             striped: true, //True 奇偶行使用不同背景色
             collapsible: false, //可折叠
             sortOrder: 'desc', //排序类型
             remoteSort: true, //定义是否从服务器给数据排序
             fitColumns: true,
             singleSelect: true,
             method: 'post',
             columns: [
                 [//							                    
                 { title: '项目编号', field: 'proid', width: 100 },
                 { title: '项目名', field: 'projectName', width: 250 },
                 
                 { title: '物料描述', field: 'material', width: 280 },
                 { title: '本月数量', field: 'thisMonthCount', width: 80 },
                 { title: '单位', field: 'unit', width: 50 },
                 { title: '单价', field: 'unitPrice', width: 80 },
                 
                 {
                     title: '到货确认时间', field: 'lastArrivalDate', width: 200, formatter: function (value, row, index) {
                         if (value != "") {

                             if (value.indexOf("-") != -1)
                                 value = value.replace(/-/g, "/");
                             return new Date(value).pattern("yyyy年M月d日 HH:mm:ss");
                         }
                     }
                 }
                 ]
             ],
             onLoadSuccess:function(data){
                 if (data.total >0) {
                     if (data.rows[0].lastArrivalDate != toptime)
                     {
                         toptime = data.rows[0].lastArrivalDate;
                         playSound();
                     }
                 }
             },
             rowStyler: function (index, row) {
                 //if (row.listprice > 80) {
                 return 'background-color:#00FF00;color:#000;';
                 //}
             },
             queryParams: { "mins": "30" },
             pagination: true, //是否开启分页
             pageNumber: 1, //默认索引页
             pageSize: 20, //默认一页数据条数
             rownumbers: true //行号
         });

     }
         </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
       <div class="easyui-panel" id="my1" style="background: #eee; height: 30px;">
               <table cellpadding="0" cellspacing="0" style="width: 100%">
                        <tr>
                            <td style="padding-left: 2px">

                                <div style="padding: 2px;">
                                   <select id="myinterval" onchange="changeset">
                        <option value="10000">10秒</option>
                        <option value="30000">30秒</option>
                        <option value="60000">1分钟</option>
                        <option value="300000">5分钟</option>
                        <option value="-1">停止</option>
                    </select>
                                      </div>
                            </td>
                        </tr>
                    </table>
            </div>
            <div id="yjfx" class="easyui-panel"  >
                <div id="container" style="min-width:400px;min-height:400px;">
                     <table id="tt">
            </table>   
                </div>
            </div>
</asp:Content>
